<template>
	<view class="page_body">
		<!-- 状态栏高度 设置背景色 占位状态栏-->
		<view style="position: fixed;width:100%;left:0;top:0;z-index: 999;">
			<view class="ztl"
				:style="{'height':statusBarHeight}"></view>
			<!-- 导航栏 -->
			<!-- 占位盒子 -->
			<view class=""
				:style="{'height': hieght}"></view>
			<navBar bgColor="#FFF">
				<image :slot="'left'"
					@click="navToBack"
					:src="xcxImgUrl && xcxImgUrl+'fanhui.svg'"
					style="width: 36rpx;height: 36rpx;"></image>
				<text :slot="'content'">确认订单</text>
			</navBar>
		</view>
		
		
		<view style="position: relative;top:120rpx" :style="{marginTop:-keyboardHeight+'px'}">	
		<scroll-view
		scroll-y
		:style="{'height': 'calc(100vh - ' + demoTopHieght +')'}"
		class="mian_confirmOrder pd10"
		>
		<view 
			@click="toAddress"
			class="mian_confirmOrder_address pd_lr10">
				<view class="mian_confirmOrder_address_l mr10">
					<image src="@/static/newpic/cartAddress.svg"></image>
				</view>
				<view class="mian_confirmOrder_address_c mr10">
					<view>
						<text class="name">{{addressInfo.name ? addressInfo.name : '未设置收货地址'}}</text>
						<text class="phone ml5">{{addressInfo.phone ? addressInfo.phone : ''}}</text>
					</view>
					<view class="address texttowShow">
							{{computedAddress}}
					</view>
				</view>
				<view class="mian_confirmOrder_address_r">
					<image :src="xcxImgUrl && xcxImgUrl+'page_public/static/youjiantou.svg'"></image>
				</view>
			</view>
			
			<view class="mian_allOrder_list_item mt10">
				<view class="list_item_top pd_lr10">
					<view class="list_item_top_left">
						商品清单
					</view>
					<view class="list_item_top_right">
						共:{{Utils.formatToFixed(countNumber,'price')}} 件
					</view>
				</view>
				<view 
				v-for="(item,index) in commonityList"
				:key="index"
				class="list_item_conter pd10">
					<view class="list_item_conter_top">
						<view class="list_item_conter_top_img"  v-if="updateNoneImg">
							<image :src="item && item.spuInfo && item.spuInfo.picture ? uploadImgUrl + item.spuInfo.picture : computedMorentu"></image>
						</view>
						<view class="list_item_conter_top_text ml5">
							<view class="list_item_conter_top_text_top texttowShow">
								{{item && item.spuInfo && item.spuInfo.name ? item.spuInfo.name : '' }}
							</view>
							<!-- 普通 -->
							<template v-if="type == 2">
								<view
								v-for="(it,inx) in item.children"
								:key="inx"
								class="list_item_conter_top_text_bom ">
									<template v-if="it.skuChecked && it.skuChecked.length && it.skuChecked[0]">
										<view class="list_item_conter_top_text_bom_item mt10">
											<text class="list_item_conter_top_text_bom_item_l">
												{{it.skuInfo &&
													 	it.skuInfo.unitInfo && 
													 	it.skuInfo.unitInfo.name &&
													 	it.skuInfo.specsOptionInfo && 
													 	it.skuInfo.specsOptionInfo.length ? 
													 	it.skuInfo.specsOptionInfo.map(it=>it.optionName).join(' ') +
														'/' +
														it.skuInfo.unitInfo.name :
													 	it.skuInfo.unitInfo.name}}
												
											</text>
											<text class="list_item_conter_top_text_bom_item_r">
												￥{{it.price ? Utils.formatToFixed(it.price,'price') : 0}} X{{it.qty ? it.qty : 0}}
											</text>
										</view>
									</template>
									<template v-else-if="it.skuChecked && it.skuChecked">
										<view class="list_item_conter_top_text_bom_item mt10">
											<text class="list_item_conter_top_text_bom_item_l">
												{{it.skuInfo &&
													 	it.skuInfo.unitInfo && 
													 	it.skuInfo.unitInfo.name &&
													 	it.skuInfo.specsOptionInfo && 
													 	it.skuInfo.specsOptionInfo.length ? 
													 	it.skuInfo.specsOptionInfo.map(it=>it.optionName).join(' ') +
														'/' +
														it.skuInfo.unitInfo.name :
													 	it.skuInfo.unitInfo.name}}
												
											</text>
											<text class="list_item_conter_top_text_bom_item_r">
												￥{{it.price ? Utils.formatToFixed(it.price,'price') : 0}} X{{it.qty ? it.qty : 0}}
											</text>
										</view>
									</template>
								</view>
							</template>
							<!-- 活动 -->
							<template v-if="type == 1">
								<view class="list_item_conter_top_text_bom ">
									<view class="list_item_conter_top_text_bom_item mt10">
										<text class="list_item_conter_top_text_bom_item_l">
											{{item.skuInfo &&
												 	item.skuInfo.unitInfo && 
												 	item.skuInfo.unitInfo.name &&
												 	item.skuInfo.specsOptionInfo && 
												 	item.skuInfo.specsOptionInfo.length ? 
												 	item.skuInfo.specsOptionInfo.map(it=>it.optionName).join(' ') +
													'/' +
													item.skuInfo.unitInfo.name :
												 	item.skuInfo.unitInfo.name}}
											
										</text>
										<text class="list_item_conter_top_text_bom_item_r">
											￥{{item.price ? Utils.formatToFixed(item.price,'price') : 0}} X{{item.qty ? item.qty : 0}}
										</text>
									</view>
									<!-- 满减 -->
									<view v-if="type == 1 && item.type == 2" class="biaoqian mt10">优惠:{{item.preferential ? Utils.formatToFixed(item.preferential,'money') : 0}}元</view>
									<!-- 秒杀 -->
									<view v-if="type == 1 && item.type == 1" class="biaoqian mt10">秒杀优惠</view>
								</view>
							</template>
						</view>
					</view>
					<!-- 活动 且 满赠活动 -->
					<template v-if="type == 1 && item.type == 3">
						<view 
						v-for="(it,inx) in item.children"
						:key="inx"
						class="list_item_conter_bom mt10">
							<view class="list_item_conter_top_img" v-if="updateNoneImg">
								<image class="zenpin" :src="xcxImgUrl && xcxImgUrl+'page_public/static/zengpin.svg'"></image>
								<image :src="it && it.spuInfo && it.spuInfo.picture ? uploadImgUrl + it.spuInfo.picture : computedMorentu"></image>
							</view>
							<view class="list_item_conter_top_text ml5">
								<view class="list_item_conter_top_text_top texttowShow">
									{{it && it.spuInfo && it.spuInfo.name ? it.spuInfo.name : '' }}
								</view>
								<view class="list_item_conter_top_text_bom ">
									<view class="list_item_conter_top_text_bom_item mt10">
										<text class="list_item_conter_top_text_bom_item_l">
											{{it.skuInfo &&
												 	it.skuInfo.unitInfo && 
												 	it.skuInfo.unitInfo.name &&
												 	it.skuInfo.specsOptionInfo && 
												 	it.skuInfo.specsOptionInfo.length ? 
												 	it.skuInfo.specsOptionInfo.map(it=>it.optionName).join(' ') +
													'/' +
													it.skuInfo.unitInfo.name :
												 	it.skuInfo.unitInfo.name}}
										</text>
										<text class="list_item_conter_top_text_bom_item_r"> X{{it.num ? it.num : 0}}</text>
									</view>
								</view>
							</view>
						</view>
					</template>
				</view>
			</view>
			
			<view class="mian_confirmOrder_detail mt10">
				<view class="mian_confirmOrder_detail_t pd_lr10">
					<view class="mian_confirmOrder_detail_t_l">
						订单详情
					</view>
				</view>
				<view class="mian_confirmOrder_detail_b pd_lr10">
					<view class="mian_confirmOrder_detail_b_r">
						<view class="mian_confirmOrder_detail_b_r_l">
							订单总金额
						</view>
						<view class="mian_confirmOrder_detail_b_r_r">
							{{Utils.formatToFixed(orderCountMoney,'money')}}元
						</view>
					</view>
					<view class="mian_confirmOrder_detail_b_r">
						<view class="mian_confirmOrder_detail_b_r_l">
							优惠金额
						</view>
						<view class="mian_confirmOrder_detail_b_r_r">
							{{Utils.formatToFixed(youhuiMoney,'money')}}元
						</view>
					</view>
					<view class="mian_confirmOrder_detail_b_r">
						<view class="mian_confirmOrder_detail_b_r_l" >
							优惠卷
						</view>
						<view class="mian_confirmOrder_detail_b_r_r" style="margin-left: 500rpx;">
							{{Utils.formatToFixed(youhuiMoney,'money')}}元
						</view>
						<view class="" style="width: 24rpx;height: 24rpx;margin-bottom:8rpx;" @click="showCoupon = true">
							<image class=""  src="/static/newpic/right.svg" style="width: 100%;height: 100%;"></image>
						</view>
					</view>
					<view class="mian_confirmOrder_detail_b_r">
						<view class="mian_confirmOrder_detail_b_r_l">
							应付金额
						</view>
						<view class="mian_confirmOrder_detail_b_r_r">
							{{Utils.formatToFixed(yinfuMoney,'money')}}元
						</view>
					</view>
					<view 
					class="mian_confirmOrder_detail_beizhu">
						<view class="mian_confirmOrder_detail_beizhu_l">
							备注信息
						</view>
						<u-textarea 
						confirmType="done"
						height='100'
						border='none'
						v-model="summary"
						maxlength="200"
						placeholder="有什么嘱咐吗？"
						 @focus="focus"
						 @blur="blur"
						 >
						</u-textarea>
					</view>
				</view>
			</view>
			
		</scroll-view>
		</view>
		
		<view class="mian_confirmOrder_btn">
			<view class="mian_confirmOrder_btn_l ">
				合计：<text style="color: #ec4141;font-size: 28rpx;">￥{{Utils.formatToFixed(yinfuMoney,'money')}}</text>
			</view>
			<view 
			@click="submit"
			class="mian_confirmOrder_btn_r">
				提交订单
			</view>
		</view>
		<!-- 领劵弹框 -->
		 <view class="show_coupon">
		 	<u-popup :show="showCoupon" mode="bottom">
		 	    <view class="show_coupon_title">
		 	        <text>领劵下单</text>
		 	    </view>
				<view class="show_coupon_content" >
					<scroll-view scroll-y="" style="height: 420rpx;">
						<view class="content">
							<view style="width:355px; height: 100px;">
								<!-- <image class=""  src="/static/newpic/couponList.svg" style="width: 100%;height: 100%;"></image> -->
								<image class=""  src="/static/newpic/couponDetails.svg" style="width: 100%;height: 100%;"></image>
							</view>
							<view class="list">
								<view class="content_left">
									<text style="font-size: 40rpx;">￥</text>
									<text style="font-weight: 700;font-size: 60rpx;color: #EC4141;">80</text>
								</view>
								<view class="content_right">
								<view class="content_title">
									<view class="content_title1" >满800减80优惠券满80优惠券满80</view>
									<view class="content_title2" >服装衣服专用服装衣服专用衣服专用</view>
									<view class="content_title3" >有效期至: 2020.08.31 23:59</view>
								</view>
									<view class="content_nouse">
									 <view class="custom_checkbox"
									 	:class="{active : checkedIndex == 1}">
									 	<u-checkbox-group :value="[checkedIndex == 1]"
									 		>
									 		<u-checkbox :name="true" activeColor="red"></u-checkbox>
									 	</u-checkbox-group>
									 </view>
									</view>
								</view>
							</view>
						</view>
						<view class="content">
							<view style="width:355px; height: 100px;">
								<!-- <image class=""  src="/static/newpic/couponList.svg" style="width: 100%;height: 100%;"></image> -->
								<image class=""  src="/static/newpic/couponDetails.svg" style="width: 100%;height: 100%;"></image>
							</view>
							<view class="list">
								<view class="content_left">
									<text style="font-size: 40rpx;">￥</text>
									<text style="font-weight: 700;font-size: 60rpx;color: #EC4141;">80</text>
								</view>
								<view class="content_right">
								<view class="content_title">
									<view class="content_title1" >满800减80优惠券满80优惠券满80</view>
									<view class="content_title2" >服装衣服专用服装衣服专用衣服专用</view>
									<view class="content_title3" >有效期至: 2020.08.31 23:59</view>
								</view>
									<view class="content_nouse">
									 <view class="custom_checkbox"
									 	:class="{active : checkedIndex == 1}">
									 	<u-checkbox-group :value="[checkedIndex == 1]"
									 		>
									 		<u-checkbox :name="true" activeColor="red"></u-checkbox>
									 	</u-checkbox-group>
									 </view>
									</view>
								</view>
							</view>
						</view>
						<view class="content">
							<view style="width:355px; height: 100px;">
								<!-- <image class=""  src="/static/newpic/couponList.svg" style="width: 100%;height: 100%;"></image> -->
								<image class=""  src="/static/newpic/couponDetails.svg" style="width: 100%;height: 100%;"></image>
							</view>
							<view class="list">
								<view class="content_left">
									<text style="font-size: 40rpx;">￥</text>
									<text style="font-weight: 700;font-size: 60rpx;color: #EC4141;">80</text>
								</view>
								<view class="content_right">
								<view class="content_title">
									<view class="content_title1" >满800减80优惠券满80优惠券满80</view>
									<view class="content_title2" >服装衣服专用服装衣服专用衣服专用</view>
									<view class="content_title3" >有效期至: 2020.08.31 23:59</view>
								</view>
									<view class="content_nouse">
									 <view class="custom_checkbox"
									 	:class="{active : checkedIndex == 1}">
									 	<u-checkbox-group :value="[checkedIndex == 1]"
									 		>
									 		<u-checkbox :name="true" activeColor="red"></u-checkbox>
									 	</u-checkbox-group>
									 </view>
									</view>
								</view>
							</view>
						</view>
					</scroll-view>
				    <view class="nouseCoupon">
				     <view class="" style="color: #333;font-size: 30rpx;">
				     	不使用优惠卷
				     </view>
					 <view class="custom_checkbox"
					 :class="{active : checkedIndex == 1}">
					 <u-checkbox-group :value="[checkedIndex == 1]"
					 >
					 <u-checkbox :name="true" activeColor="red"></u-checkbox>
					 </u-checkbox-group>
					</view>
				    </view>
				</view>
		 		<view class="show_coupon_bottom">
		 			确定
		 		</view>
		 	</u-popup>
		 </view>
	</view>
</template>

<script>
	import {uploadImgUrl} from "@/utils/request.js"
	import {getDefaultMallCustomerAddress} from '@/api/setting.js'
	import {addMallOrder} from '@/api/global.js'
	import {
		mapGetters
	} from 'vuex'
	export default {
		computed: {
			...mapGetters(['demoTopHieght']),
			//返回默认地址
			computedAddress(){
				let province = this.addressInfo?.province || ''
				let city = this.addressInfo?.city || ''
				let area = this.addressInfo?.area || ''
				let address = this.addressInfo?.address || ''
				if(province == '' && city == '' && address == ''){
					return '您还没设置收货地址，点击添加收货地址'
				}else{
					return province + city + area + address
				}
			},
			//返回默认图
			computedMorentu(){
				return this.$store?.state?.morentu
			},
			//返回有图无图控制
			updateNoneImg() {
				return this.$store.state.configSetting.noneImge == 1 ? false : true
			},
		},
		data() {
			return {
				showCoupon:false,//确认订单
				lasttime:'',
				isLoading: false,
				uploadImgUrl,
				statusBarHeight:'',
				hieght:'',
				type:1,//区分是从哪个购物车页面过来的 1.活动 2.普通
				summary:'',//备注
				addressInfo:{},//默认收货地址
				commonityList:[],//购物车商品信息
				orderCountMoney:0,//订单总金额
				youhuiMoney:0,//优惠金额
				yinfuMoney:0,//应付金额
				countNumber:0,//总数量
				activityId:0,//活动id
				activeType:0,//活动类型
				cartType:``,//购物车类型
				keyboardHeight:0
			};
		},
		onLoad(options) {
			console.log('options',options)
			//区分是从哪个购物车页面过来的 1.活动 2.普通
			this.type = options?.type || 1
			this.cartType = options?.cartType || ``;
			//活动id
			this.activityId = options?.activityId || this.$store?.state?.activityInfo?.activityId
			this.activeType = options?.activeType || this.$store?.state?.activityInfo?.activeType
			console.log(this.activityId,this.activeType);
			//如果携带的有地址 是切换 不调接口
			if(options?.address){
				//切换地址
				this.addressInfo = JSON.parse(options?.address) || ''
			}else{
				//获取默认收货地址
				this.getAddress()
			}
			//获取购物车商品信息
			this.commonityList = this.$store?.state?.cardCommonity || [] 
			console.log(this.commonityList,'commonityList');
			//计算总计
			this.getMoney()
		},
		onHide() {
			this.isLoading = false
		},
		onShow() {
			this.$nextTick(() => {
				// 获取状态栏的高度
				this.statusBarHeight = this.$store.state.statusBarHeight * 2 + 'rpx'
				// 计算站位的高度
				this.hieght = (this.$store.state.navBarHeight) * 2 + 'rpx'
				console.log(this.hieght);
				//获取高度
				this.Utils.getDemoTopHeight('mian_confirmOrder')
			})
		},
		methods:{
			focus(e){
				console.log(e.detail.height,890)
				this.keyboardHeight = e.detail.height;
			},
			blur(){
				this.keyboardHeight = 0;
			},
			//提交订单
			async submit(){
			this.summary = this.summary.substring(0,200)
		     let d = new Date();
		     let nowtime = d.getTime();//获取点击时间
		     if(nowtime - this.lasttime < 2000){  //如果两次点击事件间隔小于2秒，则不触发后面的接口。
		      return;
		     };
		     this.lasttime = nowtime;
			 if(!this.isLoading){
				 this.isLoading = true
				 console.log('1111111111')
				 
				 console.log(this.commonityList);
				 console.log(this.$store.state.configSetting.startOrderMoney*1,this.yinfuMoney*1)
				 if(this.$store.state.configSetting.startOrderMoney*1 > this.yinfuMoney*1){
				 	this.Utils.toast(`不能低于起订金额${this.$store.state.configSetting.startOrderMoney}`);
				 	return;
				 }
				 //获取sku信息json
				 let json = []
				 if(this.type == 2){ //普通商品
				 	this.commonityList.forEach(item=>{
				 		//先筛选所有skuInfo对象
				 		item.children.filter(it=>it.skuChecked).forEach(it=>{
				 			json.push(
				 				{
				 				commodityId: it?.commodityId || 0,
				 				commodityDetailId: it?.commodityDetailId || 0,
				 				qty: it?.qty || 0,
				 				price: it?.price || 0,
				 				money: it?.money || 0,
				 				// preferential: '', // 活动
				 				summary: it?.summary || '',
				 				branchId: it?.branchId || 0,
				 				accountId:it?.accountId || 0,
				 				bussinessId: it?.bussinessId || 0,
				 				}
				 			)
				 		})
				 	})
				 	
				 }
				 
				 if(this.type == 1){ //活动商品
				 	this.commonityList.forEach(item=>{
				 		json.push(
				 			{
				 			commodityId: item?.commodityId || 0,
				 			commodityDetailId: item?.commodityDetailId || 0,
				 			qty: item?.qty || 0,
				 			price: item?.price || 0,
				 			money: item?.money || 0,
				 			preferential: item?.preferential || 0, // 活动优惠金额
				 			summary: item?.summary || '',
				 			branchId: item?.branchId || 0,
				 			accountId:item?.accountId || 0,
				 			bussinessId: item?.bussinessId || 0,
				 			activityDetailId:item?.activityDetailId || 0,
				 			// parentid:item?.children?.[0]?.parentId || 0
				 			}
				 		)
				 		if(item.type == 3 && item.children){ //满赠 有赠品
				 			// 循环children
				 			item.children.forEach(it=>{
				 				json.push(
				 					{
				 					commodityId: it?.commodityId || 0,
				 					commodityDetailId: it?.commodityDetailId || 0,
				 					qty: it?.num || 0,
				 					price: it?.price || 0,
				 					money: it?.money || 0,
				 					preferential: it?.preferential || 0, // 活动优惠金额
				 					summary: it?.summary || '',
				 					branchId: item?.branchId || 0,
				 					accountId:item?.accountId || 0,
				 					bussinessId: item?.bussinessId || 0,
				 					activityDetailId:item?.activityDetailId || 0,
				 					parentid:it?.parentId || 0
				 					}
				 				)
				 			})
				 		}
				 	})
				 }
				 let res = await addMallOrder({
				 	money:this.orderCountMoney,//订单总金额
				 	preferential:this.youhuiMoney,//优惠金额
				 	styleQty:this.commonityList.length,//商品种类数量
				 	qty:this.countNumber,//商品总件数
				 	summary:this.summary,//订单备注
				 	recipient:this?.addressInfo?.name || '',//收件人
				 	phone:this?.addressInfo?.phone || '',//
				 	province:this?.addressInfo?.province || '',//省
				 	city:this?.addressInfo?.city || '',//市
				 	area:this?.addressInfo?.area || '',//区
				 	address:this?.addressInfo?.address || '',//详细地址
				 	details:JSON.stringify(json),//订单详情
				 	payDetails:'',//暂时不传 付款明细
				 	activityId:this.type == 1 ? this.activityId : '',//活动id
				 	warehouseId:this.$store?.state?.warehouseInfo?.warehouseId || '',//仓库id
				 	type:this.cartType || ``
				 })
				 if(res.code == 2000){
				 	this.Utils.toast(`提交成功`)			
				 	if(this.yinfuMoney == 0){
				 	    setTimeout(() => {
				 			uni.navigateTo({
				 				url: '/page_public/successPay'
				 			})
				 		},500)	
				 	}else {
				 		setTimeout(()=>{
				 			uni.navigateTo({
				 				url:`/page_public/surePay?type=${this.type}&yinfuMoney=${this.yinfuMoney}&orderId=${res.data.info}`
				 			})
				 		},500)
				 	}
				 	
				 }else{
				 	this.Utils.toast(`${res.msg}`)
				 }
				 this.isLoading = false
			 }
			},
			//计算订单信息中的金额
			getMoney(){
				//如果有商品 计算
				if(this.commonityList.length){
					//普通商品
					if(this.type == 2){
						//计算订单总金额
						// 循环spu
						let pirceArr = []
						this.commonityList.forEach(item=>{
							//拿出每个sku的money
							pirceArr.push(...item.children.filter(it=>it.skuChecked && it.skuChecked.length ? it.skuChecked[0] : it.skuChecked).map(it=>it.money || 0))
						})
						console.log(pirceArr);
						//累加计算订单总金额 
						this.orderCountMoney =  pirceArr.reduce((init,item)=>{
							return init += item*1
						},0)
						
						//计算应付金额 及 总计
						console.log(this.orderCountMoney,this.youhuiMoney)
						this.yinfuMoney = this.orderCountMoney - this.youhuiMoney
						
						//计算总数量
						console.log(this.commonityList,'this.commonityList')
						let numberArr = []
						this.commonityList.forEach(item=>{
							//拿出每个sku的qty
							numberArr.push(...item.children.filter(it=>it.skuChecked && it.skuChecked.length ? it.skuChecked[0] : it.skuChecked).map(it=>it.qty))
						})
						console.log(this.commonityList,123)
						this.commonityList = this.commonityList.map(v => {
							v.children = v.children.filter(a => a.skuChecked && a.skuChecked.length ? a.skuChecked[0] : a.skuChecked);
							return v;
						})
						//累加计算总数量
						console.log(numberArr);
						
						this.countNumber = numberArr.map(item => parseInt(item) ).reduce((init,item)=>{
							
							return init += item
						},0)
						console.log(this.countNumber);
					}
					//活动商品
					if(this.type == 1){
						//计算订单总金额
						// 循环spu
						let pirceArr = []
						this.commonityList?.forEach(item=>{
							//拿出每个sku的money
							pirceArr.push(item.money)
						})
						console.log(pirceArr);
						//累加计算订单总金额 
						this.orderCountMoney =  pirceArr.reduce((init,item)=>{
							return init += item
						},0)
						
						//计算优惠
						let preferentialArr = []
						this.commonityList?.forEach(item=>{
							//拿出每个sku的money
							preferentialArr.push(item.preferential ? item.preferential : 0)
						})
						console.log(preferentialArr);
						//累加计算优惠
						this.youhuiMoney =  preferentialArr.reduce((init,item)=>{
							return init += item
						},0)
						
						//计算应付金额 及 总计
						this.yinfuMoney = this.orderCountMoney - this.youhuiMoney
						
						//计算总数量
						let numberArr = []
						this.commonityList?.forEach(item=>{
							//满赠
							if(item.type == 3 && item.children){
								item.children.forEach(it=>{
									numberArr.push(it.num)
								})
							}
							//拿出每个sku的qty
							 numberArr.push(item.qty)
						})
						//累加计算总数量
						console.log(numberArr);
						this.countNumber =  numberArr.reduce((init,item)=>{
							return init += item
						},0)
						
					}
					
				}
				
			},
			//获取默认地址
			async getAddress(){
				let res = await getDefaultMallCustomerAddress()
				if(res.code == 2000){
					this.addressInfo = res?.data?.info || {}
				}else{
					this.Utils.toast(`${res.msg}`)
				}
			},
			//返回上一级
			navToBack(){
				if(this.type == 2){
					uni.switchTab({
						url:'/pages/shoppingCard/shoppingCard'
					})
				}
				else{
					uni.navigateBack();
					// uni.navigateTo({
						// url:`/page_activity/activeCard?activeType=${this.activeType}&activityId=${this.activityId}`
					// })
				}
			},
			//去地址管理
			toAddress(){
				uni.navigateTo({
					url:`/page_public/address?type=${this.type}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.mian_confirmOrder{
		width: 100%;
		box-sizing: border-box;
		padding-bottom: 100rpx;
		.mian_confirmOrder_address{
			width: 100%;
			height: 200rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			background-color: #FFF;
			border-radius: $border_radius_10;
			.mian_confirmOrder_address_l{
				width: 60rpx;
				height:60rpx;
				image{
					width: 100%;
					height: 100%;
				}
			}
			.mian_confirmOrder_address_c{
				flex: 1;
				.name{
					font-weight: bold;
					font-size: 32rpx;
					color: $text_color_333;
				}
				.phone{
					font-size: $font_size_14;
					color: $text_color_808080;
					font-weight: bold;
				}
				.address{
					font-size: $font_size_14;
					color: $text_color_333;
				}
			}
			.mian_confirmOrder_address_r{
				width: 24rpx;
				height:24rpx;
				image{
					width: 100%;
					height: 100%;
				}
			}
		}
		
		.mian_allOrder_list_item{
			background-color: #FFF;
			width: 100%;
			border-radius: $border_radius_10;
			box-sizing: border-box;
			.list_item_top{
				height: 88rpx;
				border-bottom: 1px solid #f3f3f3;
				display: flex;
				align-items: center;
				justify-content: space-between;
				color: $text_color_333;
					.list_item_top_left{
						color: $text_color_333;
						font-size: 32rpx;
						font-weight: bold;
					}
					.list_item_top_right{
						font-size: $font_size_14;
					}
			}
			.list_item_conter{
				border-bottom: 1px solid #f3f3f3;
				.list_item_conter_top,
				.list_item_conter_bom{
					display: flex;
					.list_item_conter_top_img{
						position: relative;
						border-radius: $border_radius_4;
						width: 160rpx;
						height: 160rpx;
						.zenpin{
							position: absolute;
							left: 0;
							top: 0;
							z-index: 999;
							width: 80rpx;
							height: 32rpx;
						}
						image{
							width: 100%;
							height: 100%;
						}
					}
					
					.list_item_conter_top_text{
						flex: 1;
						width: 400rpx;
						.list_item_conter_top_text_top{
							font-size: $font_size_12;
							color: $text_color_333;
						}
						.list_item_conter_top_text_bom{
							.list_item_conter_top_text_bom_item{
								font-size: $font_size_12;
								display: flex;
								justify-content: space-between;
								.list_item_conter_top_text_bom_item_l{
									color: $text_color_808080;
									width: 300rpx;
								}
								.list_item_conter_top_text_bom_item_r{
									color: $text_color_333;
									width: 158rpx;
								}
							}
							.biaoqian{
								font-size: $font_size_12;
								color: $text_color_ec4141;
								padding: 4rpx;
								background-color: rgba(255, 227, 227, 1);
								width: 150rpx;
								max-width: 300rpx;
								border-radius: $border_radius_4;
								text-align: center;
								float: right;
							}
							
						}
					}
				}
				.list_item_conter_bom{
					margin-left: 100rpx;
				}
			}
			
			
		}
		
		.mian_confirmOrder_detail{
			background-color: #FFF;
			width: 100%;
			border-radius: $border_radius_10;
			box-sizing: border-box;
			
			.mian_confirmOrder_detail_t{
				height: 88rpx;
				border-bottom: 1px solid #f3f3f3;
				display: flex;
				align-items: center;
				justify-content: space-between;
				
				.mian_confirmOrder_detail_t_l{
					color: $text_color_333;
					font-size: 32rpx;
					font-weight: bold;
				}
			}
			.mian_confirmOrder_detail_b{
				.mian_confirmOrder_detail_b_r{
					height: 88rpx;
					border-bottom: 1px solid #f3f3f3;
					display: flex;
					align-items: center;
					justify-content: space-between;
					font-size: $font_size_14;
					.mian_confirmOrder_detail_b_r_l{
						color: $text_color_808080;
					}
					.mian_confirmOrder_detail_b_r_r{
						color: $text_color_333;
					}
				}
				.mian_confirmOrder_detail_beizhu{
					height: 200rpx;
					border-bottom: 1px solid #f3f3f3;
					display: flex;
					font-size: $font_size_14;
					color: $text_color_808080;
					.mian_confirmOrder_detail_beizhu_l{
						margin-top: 20rpx;
					}
					/deep/.uni-textarea-placeholder{
						font-size: $font_size_14;
					}
					/deep/.uni-textarea-textarea{
						font-size: $font_size_14;
					}
				}
			}
		}
		
		
	}
	
	.mian_confirmOrder_btn{
		width: 100%;
		height: 88rpx;
		box-sizing: border-box;
		background-color: #FFF;
		position: fixed;
		left: 0;
		bottom: 0;
		display: flex;
		align-items: center;
		.mian_confirmOrder_btn_l{
			font-size: $font_size_12;
			flex: 1;
			margin-left: 20rpx;
		}
		.mian_confirmOrder_btn_r{
			width: 280rpx;
			height: 100%;
			background-color: $text_color_ec4141;
			color: #fff;
			font-size: 32rpx;
			font-weight: bold;
			line-height: 88rpx;
			text-align: center;
		}
	}
//弹框
	.show_coupon {
		width: 750rpx;
		height: 800rpx;
		background: inherit;
		background-color: rgba(255, 255, 255, 1);
		border: none;
		border-radius: 10px;
		border-bottom-right-radius: 0px;
		border-bottom-left-radius: 0px;
		.show_coupon_title {
			font-weight: 700;
			font-style: normal;
			font-size: 32rpx;
			height: 100rpx;
			line-height: 100rpx;
			text-align: center;
			border-bottom: 2rpx solid #e6e6e6;
			color: #333;
		}
		.content {
			 padding: 20rpx;
		    margin-top: 14rpx;
			position: relative;
			 height: 166rpx;
			 .list {
			 	    width: 710rpx;
			 	    height: 200rpx;
					display: flex;
					position: absolute;
					left:0;
					top:0;
					.content_left {
						width: 200rpx;
						text-align: center;
						line-height: 192rpx;
						font-size: 60rpx;
						margin: 20rpx;
						color: #EC4141;
					}
					.content_right {
						display: flex;
						.content_title {
							width: 170px;
							margin: 30rpx 0 30rpx 10rpx;
							color: #EC4141;
							.content_title1 {
							font-size: 30rpx;
							margin-top:20rpx;
							font-weight: 700;
							width: 340rpx;
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
							}
							.content_title2 {
							font-size: 24rpx;
							margin-top:20rpx;
							width: 330rpx;
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
							}
							.content_title3 {
							font-size: 24rpx;
							margin-top:20rpx
							}
						}
						.content_nouse {
							    width: 40rpx;
							    height: 40rpx;
							    margin-top: 57rpx;
							    margin-left: 54rpx;
							    font-size: 28rpx;
							   margin-bottom: 150rpx;
							   .custom_checkbox {
							   			margin-top: 50rpx;
							   			margin-left: 20rpx
							   		}
							  
						}
					}
					
			 }
		}
		.show_coupon_bottom {
			font-size: 32rpx;
			height: 90rpx;
			color:#ffffff;
			background-color: rgba(243, 51, 64, 1);
			margin-top: 80rpx;
			line-height: 90rpx;
			text-align: center;
		}
		.nouseCoupon {
			    display: flex;
			    padding-left: 40rpx;
			    width: 710rpx;
			    height: 106rpx;
			    background-color: rgba(255, 255, 255, 1);
			    box-sizing: border-box;
			    border-width: 2rpx;
			    border-style: solid;
			    border-color: rgba(230, 230, 230, 1);
			    border-radius: 20rpx;
				line-height: 106rpx;
				margin-left: 20rpx;
				margin-top: 20rpx;
				.custom_checkbox {
								margin-top: 30rpx;
								margin-left: 408rpx;
						}
				
		}
		
	}
</style>
